package com.allwees.bs.c.module.share.req;

import com.allwees.bs.core.modelbase.validate.ValidateItem;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * 用户点击分享链接后的访问上报
 *
 * @author yangylsky
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ShareAccessReq extends ShareEventReq {
    /**
     * 加密串
     */
    private String d;
    /**
     * Share uuid
     */
    private String s_uid;

    /**
     * sharerUuid uuid
     */
    private String sr_uid;

    /**
     * bsKey uuid
     */
    private String k;

    @Override
    public ValidateItem[] getValidateItems() {
        return ArrayUtils.addAll(super.getValidateItems(),
                new ValidateItem(StringUtils.isBlank(d), "d can not be empty"),
                new ValidateItem(StringUtils.isBlank(s_uid), "s_uid can not be empty"),
                new ValidateItem(StringUtils.isBlank(sr_uid), "sr_uid can not be empty"),
                new ValidateItem(StringUtils.isBlank(k), "k can not be empty"),
                new ValidateItem(platform == null, "platform can not be a null"),
                new ValidateItem(type == null, "type can not be a null"));
    }

    @Override
    protected Object[] signValues() {
        return new Object[]{d, s_uid, sr_uid, k, platform.name(), type.name(), getTime().getTime()};
    }

    @Override
    protected String signSeparator() {
        return platform.isApp() ? "_SAAR_" : "_SWAWM_";
    }

//    public ActionLogDTO toLogBo() {
//    	ActionLogDTO bo = new ActionLogDTO().setUaType(EActionType.SHARE_ACCESS);
//		bo.updateRequestInfo()
//				.setClientIp(ip)
//				.setPlatform(platform)
//				.setTypeName(type.name()) //EShareType
//				.setKey(k) //TargetUuid
//				.setShareUuid(s_uid) //ShareUuid
//				.setSharerUuid(sr_uid)
//				.updateRequestInfo(); //SharerUuid
//		return bo;
//    }
}
